﻿using FlexFlow.Base.Interface;
using FlexFlow.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlexFlow.Base.Interface
{
    /// <summary>
    /// 表示用户权限提供器接口
    /// </summary>
    public interface IUserPermissionProvider : IPhysicalEntityProvider<UserPermission>
    {
        /// <summary>
        /// 取得指定权限
        /// </summary>
        /// <param name="defId">
        /// 权限定义Id
        /// </param>
        /// <param name="userId">
        /// 用户Id
        /// </param>
        /// <param name="orgId">
        /// 组织机构Id
        /// </param>
        /// <param name="value">
        /// 权限值
        /// </param>
        /// <param name="tag">
        /// 权限备注
        /// </param>
        /// <returns>
        /// 表示取得的权限，如果权限不存在，返回null
        /// </returns>
        /// <remarks>
        /// userId与orgId的比较为或关系，即匹配userId后无需匹配orgId
        /// </remarks>
        UserPermission Get(Guid defId, Guid userId, Guid orgId, string tag, bool value);
        /// <summary>
        /// 通过权限定义ID取得用户权限实例
        /// </summary>
        /// <param name="defId">
        /// 权限定义Id
        /// </param>
        /// <param name="tag">
        /// 权限定义附加信息
        /// </param>
        /// <returns>
        /// 取得的用户权限实例
        /// </returns>
        UserPermission GetByDefineId(Guid defId, string tag);
        /// <summary>
        /// 更新指定的权限
        /// </summary>
        /// <param name="identity">
        /// 权限Id
        /// </param>
        /// <param name="users">
        /// 用户列表，为null则表示不更新用户
        /// </param>
        /// <param name="orgs">
        /// 组织机构列表，为null则表示不更新组织机构
        /// </param>
        /// <returns>
        /// 一个值，表示操作是否成功
        /// </returns>
        bool Update(Guid identity, string users = null, string orgs = null);
    }
}
